#pragma once
#include "sdk/ohos/ohos_screen_capturer.h"
#include "sdk/ohos/ohos_screen_capturer_wrap.h"
#include "media/base/media_channel.h"
#include "modules/video_capture/video_capture.h"
#include "modules/video_capture/video_capture_defines.h"
#include "rtc_client/render/njs_video_render.h"
#include "sdk/ohos/ohos_peer_connection_factory.h"

namespace ohosrtc {
class NJSScreenCapture : public rtc::VideoSinkInterface<webrtc::VideoFrame>  {
  public:
    NJSScreenCapture(int width, int height, int targetFps, webrtc::PeerConnectionFactoryInterface* pcFactoryPtr, rtc::Thread *worker_thread);
    virtual ~NJSScreenCapture() = default;

    bool StartCapture();
    void StopCapture();
    void SetWindowOrientation(int orientation);
    void SetSensorOrientation(int orientation);

    void OnFrame(const webrtc::VideoFrame &frame);

    void BindPreviewRender(std::string renderId);
     
    void BindSink(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink);
  
  private:
    std::uint32_t width_, height_, targetFps_;
    std::unique_ptr<webrtc::ScreenCapturerOhosWrap> screen_cap_wrap_;
    webrtc::VideoCaptureCapability capability_;
    std::list<std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>>> sinks_;
};
}